package com.coolbi.onsupai.core.dao.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;

import com.coolbi.onsupai.core.dao.MerchantDao;
import com.coolbi.onsupai.core.entity.Merchant;
import com.coolbi.onsupai.core.mapper.MerchantMapper;

public class MerchantDaoImpl implements MerchantDao {
	
	@Autowired
	private MerchantMapper merchantMapper;

	public void setMerchantMapper(MerchantMapper merchantMapper) {
		this.merchantMapper = merchantMapper;
	}

	@Override
	public Merchant save(Merchant obj) {
		merchantMapper.save(obj);
		return obj;
	}

	@Override
	public int delete(long id) {
		return merchantMapper.delete(id);
	}

	@Override
	public int update(Merchant obj) {
		return merchantMapper.update(obj);
	}

	@Override
	public Merchant get(long id) {
		return merchantMapper.get(id);
	}

	@Override
	public List<Merchant> list() {
		return merchantMapper.list();
	}

	@Override
	public List<Merchant> listByPage(int offset, int limit) {
		Map<String,Object> parameter = new HashMap<String,Object>();
		parameter.put("offset", offset);
		parameter.put("limit", limit);
		return merchantMapper.listByPage(parameter);
	}

	@Override
	public List<Merchant> find(Map<String, Object> parameter) {
		return merchantMapper.listByParameter(parameter);
	}

	@Override
	public List<Merchant> findByPage(Map<String, Object> parameter, int offset,
			int limit) {
		return merchantMapper.listByParameterPage(parameter);
	}

	@Override
	public List<Merchant> search(Map<String, Object> parameter, int offset,
			int limit) {
		return merchantMapper.search(parameter);
	}

	@Override
	public int count() {
		return merchantMapper.count();
	}

	@Override
	public int countByKeyWord(Map<String, Object> parameter) {
		return merchantMapper.countByKeyWord(parameter);
	}

	@Override
	public int count(Map<String, Object> parameter) {
		return merchantMapper.countByParameter(parameter);
	}

	@Override
	public int countByMerchantNo(String merchantNo) {
		return merchantMapper.countByMerchantNo(merchantNo);
	}

	@Override
	public int countByTelephone(String telephone) {
		return merchantMapper.countByTelephone(telephone);
	}

	@Override
	public int countByEmail(String email) {
		return merchantMapper.countByEmail(email);
	}

}
